﻿<%@ Page Title="调拨结果明细" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server"></script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../assets/css/plugins/boxdrop/boxDrop.css" rel="stylesheet" />
    <link href="../assets/css/plugins/iCheck/customsmall.css" rel="stylesheet" />
    <link href="../assets/css/shelf/base.css" rel="stylesheet">
    <link href="../assets/css/report/AllocationDetail.css" rel="stylesheet" />
    <style>
        .system-box .right-side {
            width: 100%;
        }

        .inmodal .modal-body {
            padding: 10px;
        }

        @media (min-width: 768px) {
            .modal-dialog {
                width: 1080px;
                margin: 30px auto;
            }
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="system-box">
        <div class="right-side">
            <div class="btns-container"></div>
            <div class="condition-container">
                <div class="condition-title">查询条件</div>
                <div class="condition conditionline1">
                    <label style="width: 60px; text-align: right;">货品年份</label>
                    <select class="form-control input-w110" id="search-year">
                        <option value="">全部</option>
                    </select>

                    <label style="width: 60px; text-align: right;">货品季节</label>
                    <select class="form-control input-w110" id="search-season">
                        <option value="">全部</option>
                    </select>

                    <label style="width: 60px; text-align: right;">系列</label>
                    <select class="form-control input-w110" id="search-series">
                        <option value="">请选择</option>
                    </select>

                    <label style="width: 60px; text-align: right;">品  类</label>
                    <select class="form-control input-w110" id="search-ModelID">
                        <option value="">请选择</option>
                    </select>

                    <label style="width: 60px; text-align: right;">小 品 类</label>
                    <select class="form-control input-w110" id="search-ItemID">
                        <option value="">请选择</option>
                    </select>

                </div>
                <div class="condition">
                    <label style="width: 60px; text-align: right;">货  号</label>
                    <input type="text" class="form-control input-w110" id="search-artnum" />

                    <label style="width: 60px; text-align: right;">调入店铺</label>
                    <input type="text" placeholder="店铺代码或名称" id="search-store-in" hidden />

                    <label style="width: 60px; text-align: right;">调出店铺</label>
                    <input type="text" placeholder="店铺代码或名称" id="search-store-out" hidden />
                </div>
                <div class="cb"></div>
            </div>
            <div class="cb" style="overflow: hidden; height: 77px; border-top: 1px solid #999;">
                <div class="leftPart">
                    <table class="leftTable leftTableTitle">
                        <thead></thead>
                    </table>
                </div>
                <div class="rightPart rightTitleScroll">
                    <table class="rightTable rightTableTitle">
                        <thead></thead>
                    </table>
                </div>
            </div>
            <div class="cb">
                <div class="leftPart leftScroll" style="overflow-y: hidden;">
                    <table class="leftTable">
                        <tbody id="leftList"></tbody>
                    </table>
                </div>
                <div class="rightPart rightScroll">
                    <table class="rightTable">
                        <tbody id="rightList"></tbody>
                    </table>
                </div>
            </div>
            <div class="pageControl"></div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script src="../assets/js/framework.js"></script>
    <script src="../assets/js/page/rScroll.js"></script>
    <script src="../assets/js/page/pageControl.js"></script>
    <script src="../assets/js/page/tableControl.js"></script>
    <script src="../assets/js/plugins/iCheck/icheck.min.js"></script>
    <script src="../assets/js/plugins/iCheck/icheckAll.js"></script>
    <script src="../assets/js/plugins/boxdrop/jquery.boxdrop.js"></script>
    <script>
        $(document).ready(function () {
            //界面太大了，默认收起左边菜单
            $('.navbar-minimalize i', window.parent.document).click();
            //模块ID
            var ModuleID = Y.getUrlParam("ModuleID");
            //页数
            var page = 1;
            //获取按钮
            commonUtil.loadBtnList(ModuleID, function () {
                $('.btns-container').append('<div style="clear: both;"></div>');
            });
            //年份
            commonUtil.bindDwGlobalVariables({ dictValue: '年份' }, ['#search-year']);
            //季节
            commonUtil.bindDwGlobalVariables({ dictValue: '季节' }, ['#search-season']);
            //获取系列
            commonUtil.bindGetDropDownList(['#search-series'], 2);
            //品类
            commonUtil.bindGetDropDownList(['#search-ModelID', '#popModelId'], 4);
            //品类获取小品类
            $(document).on("change", "#search-ModelID", function () {
                $("#search-ItemID").html('<option value="">请选择</option>');
                if ($(this).val() == "") {
                    return;
                }
                commonUtil.bindDropDownItem(['#search-ItemID'], $(this).val()); //小品类
            });
            //调入店铺控件初始化
            $('#search-store-in').boxDrop({ width: 120 });
            $('#search-store-in').on("boxdrop_open", function () {
                $(this).boxDrop("load", {});
            });
            //调出店铺控件初始化
            $('#search-store-out').boxDrop({ width: 120 });
            $('#search-store-out').on("boxdrop_open", function () {
                $(this).boxDrop("load", {});
            });

            //计算表格高度
            //var sUserAgent = navigator.userAgent.toLowerCase();
            var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串  
            var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器  
            var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器  
            var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器  
            var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器  
            var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器  
            var isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1 && !isEdge; //判断Chrome浏览器 
            var changeTableHeight = function () {
                if (isChrome) {
                    $('.leftScroll').css({ height: ($('.right-side').height() - $('.condition-container').outerHeight() - 146) + 'px' });
                    $('.rightScroll').css({ height: ($('.leftScroll').height() + 6) + 'px' });
                    $('.rightScroll').css({ width: ($('.rightTitleScroll').width() + 6) + 'px' });
                } else {

                    $('.leftScroll').css({ height: ($('.right-side').height() - $('.condition-container').outerHeight() - 160) + 'px' });
                    $('.rightScroll').css({ height: ($('.leftScroll').height() + 17) + 'px' });
                    $('.rightScroll').css({ width: ($('.rightTitleScroll').width() + 6) + 'px' });
                }
            }
            //重新计算表格高度
            $(window).resize(function () {
                changeTableHeight();
            });

            //右表格滚动事件
            $('.rightScroll').scroll(function () {
                $('.leftScroll').scrollTop($('.rightScroll').scrollTop());
                $('.rightTitleScroll').scrollLeft($('.rightScroll').scrollLeft());
            });


            //无数据处理
            var dealNull = function () {
                var tempChild = [];
                var tempChild2 = [];
                var tempLeftWidth = $('.leftPart').width() - 3;
                var tempRightWidth = $('.rightTableTitle').width();
                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:' + tempLeftWidth + '"><i class="fa fa-frown-o"> 暂无数据</i></span>', tdId: '', tdClass: '' });
                var tempTr = { trClass: '', children: tempChild };
                tableControl.initTbody('.leftTable', [tempTr], 0, null);
                tempChild2.push({ tdText: ' ', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:' + (tempRightWidth - 8) + 'px"><i class="fa fa-frown-o"> 暂无数据</i></span>', tdId: '', tdClass: '' });
                tempTr = { trClass: '', children: tempChild2 };
                tableControl.initTbody('.rightTable', [tempTr], 0, null);
                $('.rightScroll tbody td').css({ maxWidth: (tempRightWidth - 6) + 'px' });
            }
            dealNull();


            //处理表头（左）
            tableControl.initThead('.leftTable', [
                {
                    trClass: '', children: [
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:40px;"><input type="checkbox" id="checkAll" /></span>', tdId: '', tdClass: 'td-h76' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:195px;">调出店铺名称</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:195px;">调入店铺名称</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:58px; ">年份/季节</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:45px;">系列</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:100px;">小品类</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:70px;">颜色/吊牌价</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:120px;">货号</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 4, tdHtml: '<span style="width:30px;">码段</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 2, tdHtml: '<span style="width:30px;">01</span>', tdId: '', tdClass: '' },
                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:30px;"> </span>', tdId: '', tdClass: '' }
                    ]
                },
                { trClass: '', children: [{ tdText: '', c: 0, r: 0, tdHtml: '<span style="width:30px;"> </span>', tdId: '', tdClass: '' }] },
                {
                    trClass: '', children: [
                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:30px;">02</span>', tdId: '', tdClass: 'td-w30' },
                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:30px;"> </span>', tdId: '', tdClass: 'td-w30 ' }
                    ]
                },
                {
                    trClass: '', children: [
                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:30px;">03</span>', tdId: '', tdClass: 'td-w30' },
                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:30px;"> </span>', tdId: '', tdClass: 'td-w30' }
                    ]
                }
            ]);


            //处理表头（右）
            var partCount = 3;	//4部分
            var arr01 = ['01', 'S', 'M', 'L', 'XL', 'XXL', '3XL', '4XL', 'JM', '', '', ''];
            var arr02 = ['02', '39', '40', '41', '42', '43', '44', '45', '', '', '', ''];
            var arr03 = ['03', '27', '28', '29', '30', '31', '32', '33', '34', '36', '37', '38'];
            var arr04 = ['上市<br/>天数', '畅滞<br/>状态', '上上周<br/>销售', '上周<br/>销售', '调后<br/>小品类<br/>流转周', '调后<br/>SKC<br/>状态'];

            var children01 = [];
            var children02 = [];
            var children03 = [];

            arr01.map(function (item, j) {
                if (j == 0) {
                    children01.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'sizeField type_' + item + ' td-w30' + ' td-noTop-border hide ' });
                } else {
                    children01.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'sizeField type_' + item + ' td-w30' });
                }
            });
            children01.push({ tdText: "", c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w30' });
            arr02.map(function (item, j) {
                var isFst = false;
                if (item == 'S' || item == '39' || item == '27') {
                    isFst = true;
                }

                if (j == 0) {
                    children02.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'sizeField type_' + item + ' td-w30 hide ' });
                } else {
                    children02.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'sizeField type_' + item + ' td-w30 ' + (isFst && i != 0 ? ' fstBorder ' : '') });
                }
            });
            children02.push({ tdText: "", c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w30' });

            arr03.map(function (item, j) {
                var isFst = false;
                if (item == 'S' || item == '39' || item == '27') {
                    isFst = true;
                }
                if (j == 0) {
                    children03.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'sizeField type_' + item + ' td-w30 hide ' });
                } else {
                    children03.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'sizeField type_' + item + ' td-w30' + (isFst && i != 0 ? ' fstBorder ' : '') });
                }
            });
            children03.push({ tdText: '合计', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w42' });

            for (var i = 0; i < partCount; i++) {
                var classStr = "";

                if (i == 0) {
                    classStr = " ";
                } else if (i == 1) {
                    classStr = 'bgHuangSe';
                } else if (i == 2) {
                    classStr = 'bgLanse';
                }

                if (i != 0) {
                    arr04.map(function (item, j) {
                        if (i != 1 || j != 5) {
                            if (j == 2 || j == 4) {
                                children01.push({ tdText: '', c: 0, r: 3, tdHtml: '<span style="width:56px;">' + item + '</span>', tdId: '', tdClass: classStr });
                            } else {
                                children01.push({ tdText: '', c: 0, r: 3, tdHtml: '<span style="width:36px;">' + item + '</span>', tdId: '', tdClass: classStr });
                            }
                        }
                    });
                }
            }
            tableControl.initThead('.rightTable', [
                {
                    trClass: '', children: [
                        { tdText: '码段分类', c: 0, r: 3, tdHtml: '', tdId: '', tdClass: 'td-w28 td-break hide' },
                        { tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' },
                        { tdText: '调入数据', c: 12, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                        { tdText: '调出店铺辅助数据', c: 5, r: 0, tdHtml: '', tdId: '', tdClass: 'fstBorder replenishment bgHuangSe' },
                        { tdText: '调入店铺辅助数据', c: 6, r: 0, tdHtml: '', tdId: '', tdClass: 'fstBorder bgLanse' }
                    ]
                },
                { trClass: '', children: children01 },
                { trClass: '', children: children02 },
                { trClass: '', children: children03 }
            ]);

            //加载列表数据
            var loadList = function () {
                pageControl.init('MvJobAllMessage', 'GetMvJobAllMessageList', {
                    OutShopIDs: $('#search-store-out').val(),
                    InShopIDs: $('#search-store-in').val(),
                    YearNo: $('#search-year').val(),
                    SeasonID: $('#search-season').val(),
                    SeriesID: $('#search-series').val(),
                    ModelID: $('#search-ModelID').val(),
                    ItemID: $('#search-ItemID').val(),
                    MaterialID: $('#search-artnum').val(),
                    Page: page,
                    Size: 100,
                    needLayer: true,
                    alwaysCallBack: function () {
                        $('#pageList').empty();
                    }
                },
                    function (result) {

                        //result.data.Items = [];//测试无数据

                        //整个页面呈田字布局，有左上表头、右上表头、左下表体、右下表体四部分。绑定的时候，需要绑定左下表体跟右下表体
                        var leftBody = [];//左下表体数据
                        var rightBody = [];//右下表体数据

                        if (!Y.checkNull(result.data)) {
                            if (result.data.Items.length > 0) {
                                result.data.Items.map(function (item, i) {
                                    //左下表体绑定
                                    var leftChildren = {
                                        trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd'),
                                        children: [
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:40px;"><input type="checkbox" class="checkItem" /></span>', tdId: '', tdClass: '' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:62px;">' + item.CompanyID + '</span>', tdId: '', tdClass: 'CompanyID hide' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:62px;">' + item.ExtrSource + '</span>', tdId: '', tdClass: 'ExtrSource hide' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:62px;">' + item.ProjectCode + '</span>', tdId: '', tdClass: 'ProjectCode hide' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:62px;">' + item.OutShopID + '</span>', tdId: '', tdClass: ' OutShopID hide' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:62px;">' + item.InShopID + '</span>', tdId: '', tdClass: ' InShopID hide' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:62px;">' + (item.SuppleDate || '') + '</span>', tdId: '', tdClass: ' SuppleDate hide' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:195px;">' + item.OutShopName + '</span>', tdId: '', tdClass: ' OutShopName' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:195px;">' + item.InShopName + '</span>', tdId: '', tdClass: 'InShopName' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:58px;">' + item.YearNo + '/' + item.SeasonName + '</span>', tdId: '', tdClass: 'YearNo' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:45px;">' + item.SeriesName + '</span>', tdId: '', tdClass: 'SeriesName' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:100px;">' + item.ItemName + '</span>', tdId: '', tdClass: 'ItemName' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:70px;">' + item.ColorName + '/' + item.ProRetailPrice + '</span>', tdId: '', tdClass: 'ColorName' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:120px;">' + item.MaterialID + '</span>', tdId: '', tdClass: 'MaterialID' },
                                            { tdText: '', c: 2, r: 0, tdHtml: '<span style="width:60px;">' + item.SizeTypeCode + '</span>', tdId: '', tdClass: 'SizeTypeCode' },
                                        ]
                                    };
                                    leftBody.push(leftChildren);
                                });

                                //右下表体绑定
                                result.data.Items.map(function (item, i) {
                                    var rightChildren = [
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" style="" value="' + 'xxx' + '"/>', tdId: '', tdClass: 'fist_1' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="" value="' + 'xxx' + '"/>', tdId: '', tdClass: '' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="number" data-id="idid" class="td-w36" value="' + 'xxx' + '"/>', tdId: '', tdClass: 'td-w36' }
                                    ];

                                    var tr = $('th.type_' + item.SizeTypeCode).parents('tr');
                                    var sum = 0;
                                    item.SizeList.map(function (item2, i) {
                                        var nIndex = tr.find('th.type_' + item2.SizeName).index();
                                        rightChildren[nIndex - 1].tdHtml = rightChildren[nIndex - 1].tdHtml.replace("xxx", (item2.Qty == '0' ? '' : item2.Qty));
                                        sum += parseInt(item2.Qty);
                                    });
                                    rightChildren[11].tdHtml = rightChildren[11].tdHtml.replace("xxx", sum);

                                    var sizeList01 = ['00000001', '00000002', '00000003', '00000004', '00000008', '00000006', '00000007', '00000009'];
                                    var sizeList02 = ['00000020', '00000021', '00000022', '00000023', '00000024', '00000025', '00000026'];
                                    var sizeList03 = ['00000027', '00000010', '00000011', '00000012', '00000013', '00000014', '00000015', '00000016', '00000029', '00000017', '00000019', '00000018'];

                                    for (var j = 0; j < rightChildren.length; j++) {
                                        if (item.SizeTypeCode == '01') {
                                            rightChildren[j].tdHtml = rightChildren[j].tdHtml.replace("idid", "id_" + sizeList01[j]);
                                        } else if (item.SizeTypeCode == '02') {
                                            rightChildren[j].tdHtml = rightChildren[j].tdHtml.replace("idid", "id_" + sizeList02[j]);
                                        } else if (item.SizeTypeCode == '03') {
                                            rightChildren[j].tdHtml = rightChildren[j].tdHtml.replace("idid", "id_" + sizeList03[j]);
                                        } else {
                                            alert('返回数据有误，请刷新页面重试');
                                        }
                                    }

                                    rightChildren.map(function (item3, i) {
                                        var tlen = 0;
                                        if (item.SizeTypeCode == '01') {
                                            tlen = sizeList01.length;
                                        } else if (item.SizeTypeCode == '02') {
                                            tlen = sizeList02.length;
                                        } else if (item.SizeTypeCode == '03') {
                                            tlen = sizeList03.length;
                                        }

                                        item3.tdHtml = item3.tdHtml.replace("xxx", '');
                                        item3.tdHtml = item3.tdHtml.replace("idid", "");
                                    });

                                    var otherChildren = [
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:36px;">' + (item.OutSaleDays || '') + '</span>', tdId: '', tdClass: 'OutSaleDays bgHuangSe' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:36px;">' + (item.OutSKCCzpFlag || '') + '</span>', tdId: '', tdClass: 'OutSKCCzpFlag bgHuangSe' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:56px;">' + (item.OutTwoWeekSaleQty || '') + '</span>', tdId: '', tdClass: 'OutTwoWeekSaleQty bgHuangSe' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:36px;">' + (item.OutWeekSaleQty || '') + '</span>', tdId: '', tdClass: 'OutWeekSaleQty bgHuangSe' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:56px;">' + (item.OutResultMcRate || '') + '</span>', tdId: '', tdClass: 'OutResultMcRate bgHuangSe' },


                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:36px;">' + (item.InSaleDays || '') + '</span>', tdId: '', tdClass: ' InSaleDays bgLanse' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:36px;">' + (item.InSKCCzpFlag || '') + '</span>', tdId: '', tdClass: ' InSKCCzpFlag bgLanse' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:56px;">' + (item.InTwoWeekSaleQty || '') + '</span>', tdId: '', tdClass: 'InTwoWeekSaleQty bgLanse' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:36px;">' + (item.InWeekSaleQty || '') + '</span>', tdId: '', tdClass: 'InWeekSaleQty bgLanse' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:56px;">' + (item.InResultMcRate || '') + '</span>', tdId: '', tdClass: 'InResultMcRate bgLanse' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span style="width:36px;">' + (item.InISbreakSizeFlag || '') + '</span>', tdId: '', tdClass: 'InISbreakSizeFlag bgLanse' }
                                    ];


                                    var leftChildren = {
                                        trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd'),
                                        children: rightChildren.concat(otherChildren)
                                    };

                                    rightBody.push(leftChildren);
                                });
                            }
                            rScroll();
                        }

                        if (leftBody.length == 0) {
                            //无数据处理
                            dealNull();
                        } else {
                            tableControl.initTbody('.leftTable', leftBody, 0, null);
                            tableControl.initTbody('.rightTable', rightBody, 0, null);
                        }

                        changeTableHeight();

                        $(".leftTable").icheckAll({
                            checkObj: ".checkItem",//表格下面的选择控件对象 选择器
                            checkAllObj: "#checkAll",//全选 选择器
                            clickoutBoxCheck: false,//点击行 不选中
                            checkboxMargin: "4px 0 0 0 "//上右下左
                        });
                    });
            }



            //查询按钮
            $('.btns-container').on('click', '#btn-search', function () {
                page = 1;
                loadList();
            });

            //鼠标焦点离开时计算合计
            $('.rightTable').on('blur', 'input', function () {
                var currentTr = $(this).parents('tr');
                var inputs = currentTr.find('input');
                var sum = 0;
                for (var i = 0; i < inputs.length - 1; i++) {//最后一个合计不要，所以-1
                    var v = $(inputs[i]).val();
                    if (v != "" || v == " ") {
                        sum += parseInt(v);
                    }
                }
                currentTr.find('input').eq(11).val(sum);
            });

            //保存按钮
            $('.btns-container').on('click', '#btn-save', function () {

                if ($('#leftList .checkItem:checked').size() == 0) {
                    swal('请选择要保存的信息');
                    return false;
                }

                var dataList = [];
                $('.leftTable .checkItem:checked').parents('tr').each(function (indexTr, elementTr) {
                    var companyId = $(elementTr).find('.CompanyID').text();
                    var extrSource = $(elementTr).find('.ExtrSource').text();
                    var projectCode = $(elementTr).find('.ProjectCode').text();
                    var outShopId = $(elementTr).find('.OutShopID').text();
                    var inShopId = $(elementTr).find('.InShopID').text();
                    var materialId = $(elementTr).find('.MaterialID').text();
                    var suppleDate = $(elementTr).find('.SuppleDate').text();
                    var sizeTypeCode = $(elementTr).find('.SizeTypeCode').text();

                    var sizeList = [];
                    var rightUpTr = $('.rightTable').find('th.type_' + sizeTypeCode).parents('tr');
                    var rightDownTr = $('#rightList').find('tr').eq($(elementTr).index());
                    var len = rightUpTr.find('th.sizeField').size();

                    for (var i = 0; i < len; i++) {
                        var sizeName = $(rightUpTr).find('th').eq(i + 1).text();
                        if (sizeName == "" || sizeName == undefined || sizeName == '合计') {
                            continue;
                        }
                        var sizeId = $(rightDownTr).find('td').eq(i).find('input').attr('data-id');
                        var qty = $(rightDownTr).find('td').eq(i).find('input').val();
                        if (qty == "" || qty == " ") {
                            qty = 0;
                        }
                        sizeList.push({ SizeName: sizeName, SizeID: sizeId.replace('id_', ''), Qty: qty });
                    }

                    dataList.push({
                        CompanyID: companyId,
                        ExtrSource: extrSource,
                        ProjectCode: projectCode,
                        OutShopID: outShopId,
                        InShopID: inShopId,
                        MaterialID: materialId,
                        SuppleDate: suppleDate,
                        SizeList: sizeList,
                        SizeTypeCode: sizeTypeCode
                    });
                });

                layer.msg('玩命加载中……', { icon: 16, shade: 0.5, time: 0, maxWidth: 200 });
                Y.API2('MvJobAllMessage', "UpdateMvJobAllMessage", { List: dataList }, function (data) {
                    layer.closeAll('dialog');
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        swal("保存成功！", '', 'success');
                    }
                });
            });

            //导出
            $(document).on("click", "#exportBtn", function () {
                var conditionsArr = [];
                var _outShopIDs = $('#search-store-out').val();
                var _inShopIDs = $('#search-store-in').val();
                var _yearNo = $('#search-year').val();
                var _seasonID = $('#search-season').val();
                var _seriesID = $('#search-series').val();
                var _modelID = $('#search-ModelID').val();
                var _itemID = $('#search-ItemID').val();
                var _materialID = $('#search-artnum').val();

                conditionsArr.push({ connector: "and", column: "InShopID", operator: "in", value: _inShopIDs });
                conditionsArr.push({ connector: "and", column: "OutShopID", operator: "in", value: _outShopIDs });
                conditionsArr.push({ connector: "and", column: "YearNo", operator: "=", value: _yearNo });
                conditionsArr.push({ connector: "and", column: "SeasonID", operator: "=", value: _seasonID });
                conditionsArr.push({ connector: "and", column: "SeriesID", operator: "=", value: _seriesID });
                conditionsArr.push({ connector: "and", column: "ModelID", operator: "=", value: _modelID });
                conditionsArr.push({ connector: "and", column: "ItemID", operator: "=", value: _itemID });
                conditionsArr.push({ connector: "and", column: "MaterialID", operator: "=", value: _materialID });

                conditionsArr = JSON.stringify(conditionsArr);

                var tempParam = {};
                tempParam.filename = "调拨结果明细";
                tempParam.filetype = "NEWGOODSMVJOBMESSAGE";
                tempParam.conditions = encodeURIComponent(conditionsArr);;
                var t = $.Export(tempParam);
            });

            //默认调用
            loadList();
            changeTableHeight();
            $('.boxSearch').css('height', '28px');
        })
    </script>
</asp:Content>

